package cn.edu.scau.cmi.xiaozhenlin.singleton;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class SingletonController {
	@FXML
	private TextArea tv_show;

	@FXML
	private TextField et_input;

	Chairman chairman;
	int count = 0;
	boolean flag;

	@FXML
	void newChairman(ActionEvent event) {
		tv_show.clear();
		String string = et_input.getText();
		if (chairman == null) {
			flag = true;
			chairman = Chairman.getInstance(this.et_input.getText());
			System.out.println("当前主席是：" + chairman.getName());
			this.tv_show.setText("第1次创建主席名称为：" + string);
		} else if (string.equals(chairman.getName())) {
			flag = true;
		} else {
			this.tv_show.setText("已经存在一位主席,那个人是：" + chairman.getName());
		}

	}

	@FXML
	void showChairman(ActionEvent event) {
		tv_show.clear();
		if (chairman != null && flag) {
			this.tv_show.setText("当前主席是：" + chairman.getName());
		} else {
			this.tv_show.setText("当前无主席");
		}
	}

}
